package edu.scau.core.Enum;

import io.swagger.v3.oas.annotations.media.Schema;

public enum RefundStatus {
    @Schema(name = "0", description = "创建中")
    cancel("已完成",0),
    @Schema(name = "1", description = "已创建")
    refund("退款异常",1);
    private final String desc;
    private final int signal;
    RefundStatus(String desc,int signal) {
        this.desc = desc;
        this.signal=signal;
    }

    public String getDesc() {
        return desc;
    }

    public int getSignal() {
        return signal;
    }

    /**
     * 通过signal获取枚举常量
     * @param signal
     * @return
     */
    public static RefundStatus getBySignal(int signal) {
        for (RefundStatus status : RefundStatus.values()) {
            if (status.getSignal() == signal) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid signal: " + signal);
    }
}
